import sequtils, sugar
proc sum*(n: int, factors: seq[int]): int =
  toSeq(1..<n)
    .filterIt(factors.any(
      (x) => x != 0 and it mod x == 0))
    .foldl(a + b, 0)